<template>
	<view class="my-page">
		<u-navbar title="安全设置" bgColor="rgba(255,255,255,0.0)" :auto-back="true" :placeholder="true">
		</u-navbar>
		<view class="info-list">
			<view class="ability" @click="gopassword()">
				<view class="ability-item">
					<view class="ability-text">
						变更密码
					</view>
					<view class="ability-right">
						<view class="right-text">

						</view>
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="ability">
				<view class="ability-item" @click="gobindGoogle" v-if="Google == false">
					<view class="ability-text">
						绑定谷歌验证
					</view>
					<view class="ability-right">
						<view class="right-text">
							尚未设定
						</view>
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
				<view class="ability-item" @click="gotisp"  v-else>
					<view class="ability-text">
						绑定谷歌验证
					</view>
					<view class="ability-right">
						<view class="right-text2">
							已绑定
						</view> 
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="ability" @click="gophone" v-if="tel == ''">
				<view class="ability-item">
					<view class="ability-text">
						绑定手机
					</view>
					<view class="ability-right">
						<view class="right-text">
							尚未设定
						</view>
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
			</view>
			<view class="ability"  @click="gotisp" v-else>
				<view class="ability-item">
					<view class="ability-text">
						绑定手机
					</view>
					<view class="ability-right">
						<view class="right-text">
							{{tel}}
						</view>
						<u-icon name="arrow-right" color="#706D6C" size="16"></u-icon>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userinfo: {},
				tel:'',
				Google:true
			}
		},
		onShow() {
			this.getuserinfo()
			this.getGoogAuth()
		},
		methods: {
			gotisp(){
				uni.showToast({
					title:'您已绑定!',
					icon:'none'
				})
			},
			gobindGoogle(){
				uni.navigateTo({
					url:'/pages/my/security/bindgoogle/index'
				})
			},
			getGoogAuth(){
				this.$Request({
					method: 'GET',
					url: '/api/member/user/getGoogAuth',
					data: {},
					ismsg: false,
				}).then(res => {
					if (res.code == 200) {
						this.Google = res.data
					}
				})
			},
			
			gopassword() {
				if (this.userinfo.phone == null) {
					uni.showToast({
						title: '请先设定手机号！',
						icon: 'none'
					})
					return
				} else {
					uni.navigateTo({
						url:'/pages/my/security/modify/index'
					})
				}
			},
			getuserinfo() {
				this.$Request({
					method: 'GET',
					url: '/api/getInfo',
					data: {},
					ismsg: false,
				}).then(res => {
					if (res.code == 200) {
						this.userinfo = res.user
						if(this.userinfo.phone!=null){
							this.tel = this.userinfo.phone
						}
					}
				})
			},
			gophone(){
				console.log(1)
				uni.navigateTo({
					url:'/pages/my/security/bindphone/index'
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my-page {
		min-height: calc(100vh - 91rpx);
		background-image: url('../../../static/goods/top-bg.png');
		background-size: 100% 561rpx;
		background-repeat: no-repeat;

		.info-list {
			padding: 0 30rpx;

			.ability {
				margin-top: 20rpx;
				box-shadow: 0rpx 0rpx 16rpx 1rpx rgba(0, 0, 0, 0.08);
				padding: 30rpx 30rpx 10rpx 30rpx;
				background-color: #ffffff;
				border-radius: 30rpx;

				.ability-item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					padding-bottom: 20rpx;
					margin-bottom: 30rpx;
					border-bottom: 1rpx solid #F0F0F0;

					.ability-text {
						font-size: 28rpx;
						color: #000000;
					}

					.ability-right {
						display: flex;
						align-items: center;

						.right-text {
							font-size: 24rpx;
							margin-right: 20rpx;
							color: #999999;
						}
						.right-text2{
							font-size: 24rpx;
							margin-right: 20rpx;
							color: #ff0000;
						}
					}
				}

				.ability-item:last-child {
					border-bottom: none;
					margin-bottom: 0;
				}
			}
		}
	}
</style>